package com.fr.chart.plot;

import com.fr.base.XMLable;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.base.equals.Equals;
import com.fr.chart.core.ChartUtils;
import java.awt.Color;
import java.io.Serializable;

public class MeterInterval
  implements Serializable, XMLable
{
  public static final String XML_TAG = "MeterInterval";
  private static final long serialVersionUID = 1530982090622488257L;
  private String label;
  private double beginValue;
  private double endValue;
  private Color backgroundColor = Color.BLACK;
  private Color outlineColor = Color.WHITE;
  private float outlineSize = 10.0F;

  public MeterInterval()
  {
  }

  public MeterInterval(String paramString, double paramDouble1, double paramDouble2)
  {
    if (paramString == null)
      throw new IllegalArgumentException("Null 'label' argument.");
    if (paramDouble1 > paramDouble2)
      throw new IllegalArgumentException("Null 'range' argument.");
    this.label = paramString;
    this.beginValue = paramDouble1;
    this.endValue = paramDouble2;
  }

  public String getLabel()
  {
    return this.label;
  }

  public void setLabel(String paramString)
  {
    if (paramString == null)
      this.label = "";
    else
      this.label = paramString;
  }

  public double getBeginValue()
  {
    return this.beginValue;
  }

  public void setBeginValue(double paramDouble)
  {
    this.beginValue = paramDouble;
  }

  public double getEndValue()
  {
    return this.endValue;
  }

  public void setEndValue(double paramDouble)
  {
    this.endValue = paramDouble;
  }

  public void setOutlineSize(float paramFloat)
  {
    this.outlineSize = paramFloat;
  }

  public float getOutlineSize()
  {
    return this.outlineSize;
  }

  public void setOutlineColor(Color paramColor)
  {
    this.outlineColor = paramColor;
  }

  public Color getOutlineColor()
  {
    return this.outlineColor;
  }

  public void setBackgroundColor(Color paramColor)
  {
    this.backgroundColor = paramColor;
  }

  public Color getBackgroundColor()
  {
    return this.backgroundColor;
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("MeterInterval").attr("label", getLabel()).attr("beginValue", getBeginValue()).attr("endValue", getEndValue()).attr("backgroudColor", getBackgroundColor().getRGB()).attr("outlineColor", getOutlineColor().getRGB()).attr("outlineSize", getOutlineSize()).end();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    String str1 = paramXMLableReader.getTagName();
    if ("MeterInterval".equals(str1))
    {
      String str2;
      if ((str2 = paramXMLableReader.getAttr("label")) != null)
        setLabel(str2);
      if ((str2 = paramXMLableReader.getAttr("beginValue")) != null)
        setBeginValue(Double.parseDouble(str2));
      if ((str2 = paramXMLableReader.getAttr("endValue")) != null)
        setEndValue(Double.parseDouble(str2));
      if ((str2 = paramXMLableReader.getAttr("backgroudColor")) != null)
        setBackgroundColor(new Color(Integer.parseInt(str2), true));
      if ((str2 = paramXMLableReader.getAttr("outlineColor")) != null)
        setOutlineColor(new Color(Integer.parseInt(str2), true));
      if ((str2 = paramXMLableReader.getAttr("outlineSize")) != null)
        setOutlineSize(Float.parseFloat(str2));
    }
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return null;
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof MeterInterval))
      return false;
    MeterInterval localMeterInterval = (MeterInterval)paramObject;
    if (!(Equals.equals(localMeterInterval.backgroundColor, this.backgroundColor)))
      return false;
    if (localMeterInterval.getBeginValue() != getBeginValue())
      return false;
    if (localMeterInterval.getEndValue() != getEndValue())
      return false;
    if (!(Equals.equals(localMeterInterval.label, this.label)))
      return false;
    if (!(Equals.equals(localMeterInterval.outlineColor, this.outlineColor)))
      return false;
    return (localMeterInterval.getOutlineSize() == getOutlineSize());
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = new JSONObject();
    localJSONObject.put("beginValue", this.beginValue);
    localJSONObject.put("endValue", this.endValue);
    if (this.label != null)
      localJSONObject.put("label", this.label);
    localJSONObject.put("outlineSize", this.outlineSize);
    localJSONObject.put("outlineColor", ChartUtils.color2JS(this.outlineColor));
    localJSONObject.put("backgroundColor", ChartUtils.color2JS(this.backgroundColor));
    return localJSONObject;
  }
}